<!doctype html>
<html class="no-js">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <title>手机号登录</title>
    <script src="/config.js"></script>
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <meta name="msapplication-TileColor" content="#0e90d2">

    <link rel="stylesheet" href="/hall/game/js/amazeui.min.css">

    <style>
        html { font-size: 10px; }
        html,body { background-color: #f0eff4; }
        body { padding-bottom: 0;margin: 0;}
        * { padding: 0;margin: 0; }
        header {top: 0;left: 0;z-index: 999;width: 100%;height: 49px; background-color: #333; color: #fff;}
        header p { margin: 0;line-height: 49px; font-size: 16px;text-align: center; }
        .register { padding: 8px 6px; font-size: 14px;}
        .res-item {position: relative;  width: 100%; border-radius: 4px; margin-bottom: 8px;background-color: #fff; }
        .res-icon {position: absolute;left: 8px;top: 5px;z-index: 100; display: inline-block;font-size: 18px;color: #9c9c9c; }
        .res-item .input-item {display: inline-block;width: 100%;padding-left: 31px;height: 40px;border: none; font-size: inherit;}
        .res-item .input-item:focus {
            outline-offset: 0;
            outline: -webkit-focus-ring-color auto -2px;
            background-color: #fefffe;
            border: 1px solid #e21945;
            outline: 0;
            -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 5px rgba(226,25,69,.3);
            box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 5px rgba(226,25,69,0.3);
        }
        .res-item .input-item:focus + .res-icon { color: #e21945; }
        .yanzhengma {position: absolute;right: 10px;top: 10px; z-index: 100;  display: inline-block;font-size: 14px; border: none;background-color: rgba(255, 0, 0, 0);
            color: #e21945;border-radius: 8px; }
        /*.yanzhengma:disabled { background-color: #ddd; }*/
        .res-btn { margin-top: 10px;padding: 0 5px; }
        .res-btn button {  background-color: #e21945;font-size: 14px; color: #fff;border-radius: 8px; line-height: 2.2;}
        .res-btn button:focus { color: #fff; }
        .icon-back {
            background-color: hsla(0,0%,70%,.7);
            padding: .3rem .3rem .2rem .2rem;
            width: 2.4rem;
            height: 2.4rem;
            text-align: center;
            line-height: 1.3rem;
            border-radius: 50%;
            color: #ddd;
            margin-top: .6rem;
            position: absolute;
            top: .3rem;
            left: 1rem;
            /*text-indent: .1rem;*/
            float:left;
            min-width: .01rem;
            /*font-size: inherit;*/
            /*font-style: normal;*/
            display: inline-block;
            -webkit-font-smoothing: antialiased;

        }
        .icon-back:before {
            content: "<";
        }
    </style>
</head>
<body>
<header>
    <!--    隐藏返回按钮兼容香港服务器登录-->
    <!-- <i class="icon-back" onclick="back()"></i>-->
    <p>手机号登录</p>
</header>
<div class="register">
    <div class="res-item">
        <input type="number" id="userPhone" placeholder="请填写手机号码" class="input-item mobile">
    </div>
    <div class="res-item">
        <input type="number" id="userCode" oninput="if(value.length>6)value=value.slice(0,6)"  placeholder="请填写验证码" class="input-item yanzheng">
        <button type="button" onclick="sendCode();" id="sendCode" class="yanzhengma">发送验证码</button>
    </div>
    <div class="res-btn">
        <button type="button" id="res-btn" onclick="confirm();" class="am-btn am-btn-block">登录</button>
    </div>
</div>
</body>
<!--[if !IE]> -->
<script src="/misc/js/jquery-2.1.4.min.js"></script>

<!-- <![endif]-->

<!--[if IE]>
<script src="/misc/js/jquery-1.11.3.min.js"></script>
<![endif]-->
<script type="text/javascript">
    if('ontouchstart' in document.documentElement) document.write("<script src='/misc/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
</script>
<script src="/misc/js/layui/layer/layer.js"></script>
<script src="/misc/js/common.js?v=1"></script>
<script type="text/javascript">

    let s = getQueryVariable('channelId');
    var channelId = s ? s : parseInt('1033');
    var loginType = 'platform';
    var homeUrl = "https://hall.boruiwangluo.com/hall/index.html?channelId=1033";


    function getQueryVariable(variable)
    {
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
            var pair = vars[i].split("=");
            if(pair[0] == variable){return pair[1];}
        }
        return(false);
    }

    function getSystemType() {
        if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
            return "ios";
        } else if (/(Android)/i.test(navigator.userAgent)) {
            return "android";
        } else {
            return "web";
        }
    }

    function back()
    {
        var personInfo = {
            action: "remove",
            iframeId: "phoneLoginDivIframe",
            redirectUrl: homeUrl,
        };
        var str = JSON.stringify(personInfo);
        window.parent.postMessage(str, "*");

    }
    function sendCode() {

        var userPhone = $("#userPhone").val();

        if (SysData.isNull(userPhone)) {
            layer.alert("请输入手机号!", {title:"&nbsp;"});
            return;
        }

        var rsp = {
            "channelId": channelId,
            "mobile": userPhone
        };

        SysHttp.post(JONO_HOST + "/user/sms/SendCode", rsp, function (rs) {
            if (rs.code != 0) {
                SysDialog.error(rs.msg);
                return;
            }

            setTimeout(roof, 100);
        });
    }

    var times = 60;
    function roof() {

        if (times == 0) {
            $("#sendCode").html('发送验证码');
            times = 60;
            return;
        }

        var userCode = $("#userCode").val();
        if (SysData.isNull(userCode)) {
            $("#sendCode").html('重新发送(' + times + 's)');
        }

        times--;

        setTimeout(roof, 1000);
    }

    function confirm() {

        var phone = $("#userPhone").val();
        var code = $("#userCode").val();

        // 未传递手机号
        if (SysData.isNull(phone)) {
            layer.alert("请输入手机号!", {title:"&nbsp;"});
            return;
        }
        if (!SysData.checkPhone(phone)) {
            layer.alert("手机号格式错误!", {title:"&nbsp;"});
            return;
        }
        if (SysData.isNull(code)) {
            layer.alert("请填写验证码!", {title:"&nbsp;"});
            return;
        }

        var systemType = getSystemType();

        var rsp = {};
        rsp['action'] = 'checkCode';
        rsp['channelId'] = channelId;
        rsp['phone'] = phone;
        rsp['code'] = code;
        rsp['systemType'] = systemType;
        if (loginType == 'appLogin') {
            SysHttp.post("/User/Login/App/appPhoneLogin", rsp, function (rs) {
                if (rs.code != 0) {
                    // 封号
                    if (rs.code == 1084) {
                        var timestemp = new Date().getTime();
                        var personInfo = {
                            action: "remove",
                            iframeId: "phoneLoginDivIframe",
                            redirectUrl: "https://hall.51fpyouxi.cn/stop.html?v=" + timestemp,
                        }
                        var str = JSON.stringify(personInfo);
                        window.parent.postMessage(str, "*");
                        return;
                    }
                    SysDialog.error(rs.msg);
                    return;
                }

                var personInfo = {
                    action: "remove",
                    iframeId: "phoneLoginDivIframe",
                    channelId: rs.data.channelId,
                    userId: rs.data.userId,
                    nickname: rs.data.nickname,
                    avatar: rs.data.avatar,
                    roleName: rs.data.roleName,
                    token: rs.data.token,
                    time: rs.data.time,
                    sign: rs.data.sign,
                    isStopService: rs.data.isStopService,
                    redirectUrl: rs.data.redirectUrl,
                    isTestUser: rs.data.isTestUser
                };
                var str = JSON.stringify(personInfo);

                window.parent.postMessage(str, "*");
            });
            return;
        }
        SysHttp.post(JONO_HOST + "/user/login/phoneLogin", rsp, function (rs) {
            if (rs.code != 0) {
                if (rs.code == 1009) {
                    // 跳转生成二维码页面
                    location.href = "/user/Login/bindPhoneQrCode?channelId=" + rsp['channelId'] + '&pro=' + location.protocol;
                    return;
                }
                // 封号
                if (rs.code == 1084) {
                    var timestemp = new Date().getTime();
                    var personInfo = {
                        action: "remove",
                        iframeId: "phoneLoginDivIframe",
                        redirectUrl: "https://hall.51fpyouxi.cn/stop.html?v=" + timestemp,
                    }
                    var str = JSON.stringify(personInfo);
                    window.parent.postMessage(str, "*");
                    return;
                }
                SysDialog.error(rs.msg);
                return;
            }

            var personInfo = {
                action: "remove",
                iframeId: "phoneLoginDivIframe",
                channelId: rs.data.channelId,
                userId: rs.data.userId,
                nickname: rs.data.nickname,
                avatar: rs.data.avatar,
                roleName: rs.data.roleName,
                token: rs.data.token,
                time: rs.data.time,
                sign: rs.data.sign,
                isStopService: rs.data.isStopService,
                redirectUrl: rs.data.redirectUrl,
                isTestUser: rs.data.isTestUser
            };
            var str = JSON.stringify(personInfo);

            window.parent.postMessage(str, "*");
        });

    }

</script>

</html>

